package com.ruoyi.web.controller.books;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.common.annotation.Anonymous;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.books.domain.BooksPerformanceVideo;
import com.ruoyi.books.service.IBooksPerformanceVideoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 非遗演视频Controller
 *
 * @author ruoyi
 * @date 2024-03-31
 */
@Anonymous
@RestController
@RequestMapping("/books/video")
public class BooksPerformanceVideoController extends BaseController
{
    @Autowired
    private IBooksPerformanceVideoService booksPerformanceVideoService;

    /**
     * 查询非遗演视频列表
     */
//    @PreAuthorize("@ss.hasPermi('books:video:list')")
    @GetMapping("/list")
    public TableDataInfo list(BooksPerformanceVideo booksPerformanceVideo)
    {
        startPage();
        List<BooksPerformanceVideo> list = booksPerformanceVideoService.selectBooksPerformanceVideoList(booksPerformanceVideo);
        return getDataTable(list);
    }

    /**
     * 导出非遗演视频列表
     */
//    @PreAuthorize("@ss.hasPermi('books:video:export')")
    @Log(title = "非遗演视频", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, BooksPerformanceVideo booksPerformanceVideo)
    {
        List<BooksPerformanceVideo> list = booksPerformanceVideoService.selectBooksPerformanceVideoList(booksPerformanceVideo);
        ExcelUtil<BooksPerformanceVideo> util = new ExcelUtil<BooksPerformanceVideo>(BooksPerformanceVideo.class);
        util.exportExcel(response, list, "非遗演视频数据");
    }

    /**
     * 获取非遗演视频详细信息
     */
//    @PreAuthorize("@ss.hasPermi('books:video:query')")
    @GetMapping(value = "/{performanceVideoId}")
    public AjaxResult getInfo(@PathVariable("performanceVideoId") Long performanceVideoId)
    {
        return success(booksPerformanceVideoService.selectBooksPerformanceVideoByPerformanceVideoId(performanceVideoId));
    }

    /**
     * 新增非遗演视频
     */
//    @PreAuthorize("@ss.hasPermi('books:video:add')")
    @Log(title = "非遗演视频", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody BooksPerformanceVideo booksPerformanceVideo)
    {
        return toAjax(booksPerformanceVideoService.insertBooksPerformanceVideo(booksPerformanceVideo));
    }

    /**
     * 修改非遗演视频
     */
//    @PreAuthorize("@ss.hasPermi('books:video:edit')")
    @Log(title = "非遗演视频", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody BooksPerformanceVideo booksPerformanceVideo)
    {
        return toAjax(booksPerformanceVideoService.updateBooksPerformanceVideo(booksPerformanceVideo));
    }

    /**
     * 删除非遗演视频
     */
//    @PreAuthorize("@ss.hasPermi('books:video:remove')")
    @Log(title = "非遗演视频", businessType = BusinessType.DELETE)
	@DeleteMapping("/{performanceVideoIds}")
    public AjaxResult remove(@PathVariable Long[] performanceVideoIds)
    {
        return toAjax(booksPerformanceVideoService.deleteBooksPerformanceVideoByPerformanceVideoIds(performanceVideoIds));
    }
}
